<template>
	<view class="container">
		<!--		<navbar title="门店详情"></navbar>-->
		<view class="swiper banner" >
			<swiper :autoplay="true" indicator-dots="true"  :circular="circular" :interval="interval"
				:duration="duration" indicator-color="#E4E4E4" indicator-active-color="#E93323" :current="swiperCur"
				@change="swiperChange">
				<block>
					<block v-for="(item, index) in bannerImgs" :key="index">
						<swiper-item :class="{ active: index == swiperCur }">
							<image :src="item" class="slide-image" mode="aspectFill"></image>
						</swiper-item>
					</block>
				</block>
			</swiper>
			<view class="current-box">
				图片{{current}}/{{bannerImgs.length}}
			</view>
		</view>
		<view class="store-info">
			<view class="left-bg">
				<view class="store_name">{{ store.mer_name }}</view>
				<view class="address">{{ store.mer_address }}</view>
				<view class="start_time">营业时间：9:00-21:00</view>
			</view>
			<view class="right-bg">
				<view class="r-top-bg" @click="goToMap">
					<image class="loc" src="/static/2images/share_vr.png"></image>
					<text class="go">带我去</text>
				</view>
				<view class="phone-ca">
					<image class="phone-c" @click="onCall" src="/static/2images/call.png"></image>
				</view>
				<view class="r-bottom-bg">
					<view class="vr-bg" @click="goToVR">VR查看</view>
				</view> 
			</view>
		</view>
		<view>
			<view class="comment-item" v-for="(item, index) in 0" :key="index">
				<image class="avatar place"></image>
				<view class="info">
					<view class="nickname">玥玥</view>
					<view class="time">2021.12.20 9:00</view>
					<view class="stars">
						<view class="star place"></view>
						<view class="star place"></view>
						<view class="star place"></view>
						<view class="star place"></view>
						<view class="star place"></view>
					</view>
					<view class="content">评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容评价内容</view>
					<view class="images">
						<image class="image place"></image>
						<image class="image place"></image>
						<image class="image place"></image>
					</view>
				</view>
			</view>
		</view>
		<view class="content" v-if="store.intro">
			<jyf-parser :domain="domain" :html="store.intro" ref="article"
				:tag-style="tagStyle"></jyf-parser>
		</view>

		<view style="height: 88px;"></view>
		<view class="action-bar">
			
			<!-- <view class="book-now" @click="goBook">立即预订</view> -->
		</view>
	</view>
</template>

<script>
	import {
		storeMerchantDetails
	} from "@/api/2_store";
	import {
		HTTP_REQUEST_URL
	} from "@/config/app";
	export default {
		data() {
			return {
				swiperCur: 0,
				circular: true,
				autoplay: true,
				interval: 3000,
				duration: 500,
				current: 1,
				domain: HTTP_REQUEST_URL,
				tagStyle: {
					img: "width:100%;display:block;",
				},
				content: 'asdfasdfasdfasd',
				store: {}
			};
		},
		computed:{
			bannerImgs(){
				if(this.store.mer_banner){
					return this.store.mer_banner.split(",")
				}
				return []
			}
		},
		onLoad(options) {
			this.id = options.id
			storeMerchantDetails({
				id: this.id
			}).then(res => {
				this.store = res.data;
			})
		},
		methods: {
			onCall(){
				uni.makePhoneCall({
				  phoneNumber: this.store.service_phone
				})
			},
			swiperChange(e) {
				this.current = e.detail.current + 1
			},
			goBook() {
				uni.navigateTo({
					url: `/pages/2_development/store/home?id=${this.id}`
				})
			},
			//联系他
			onContact() {
				uni.makePhoneCall({
					phoneNumber: this.store.service_phone
				})
			},
			goToMap() {
				let {lat, long, mer_address} = this.store;
				console.info(this.store);
				if(lat && long) {
					uni.openLocation({
				   　　latitude: Number(lat), 
				   　　longitude: Number(long),
				   　　name: mer_address,
				   　　success() {
					   　　console.log('success');
				   　　}
					});
				}
			},
			goToVR() {
				let url = this.store.vr_link
				if(url) {
					uni.navigateTo({
					  url: `/pages/2_development/hotel/vr?url=${url}`
					})
				}
			},
		}
	}
</script>

<style lang="scss">
	.container{
		padding-bottom: 0;  
		  padding-bottom: constant(safe-area-inset-bottom);  
		  padding-bottom: env(safe-area-inset-bottom);
	}
	.banner {
		height: 213px;
		width: 100%;
		position: relative;
	
		swiper {
			height: 100%;
			width: 100%;
	
			image,
			video {
				width: 100%;
				height: 100%;
			}
	
		}
	
		.current-box {
			position: absolute;
			right: 20rpx;
			bottom: 20rpx;
			background: rgba(0, 0, 0, .24);
			color: #fff;
			border-radius: 30px;
			padding: 2px 6px;
			font-size: 20rpx;
		}
	
	}
	page {
		background: #f8f8f8;
	}


	.swiper {
		width: 100%;
		height: 230px;
	}

	.content {
		padding: 20rpx;
		background-color: #FFFFFF;
	}

	.store-info {
		padding: 15px;
		position: relative;
		background-color: #fff;
		margin-bottom: 10px;
		display: flex;
		flex-direction: row;
		
		.left-bg{
			flex: 1;
			margin-right: 15px;
			
			.store_name{
				font-weight: bold;
				font-size: 30rpx;
				color: #0b0b0b;
			}
			.address{
				font-size: 24rpx;
				color: #111;
				margin-top: 40rpx;
			}
			.start_time{
				font-size: 24rpx;
				color: #333;
				margin-top: 22rpx;
			}
		}
		.right-bg{
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			align-items: right;
			
			.r-top-bg{
				display: flex;
				flex-direction: column;
				align-items: center;
				.loc{
					width: 39rpx;
					height: 39rpx;
				}
				.go{
					font-size: 22rpx;
					color: #333;
					margin-top: 7rpx;
				}
			}
			.phone-ca{
				display: flex;
				flex-direction: column;
				align-items: center;
				margin-top:20rpx;
				
				.phone-c{
					width: 39rpx;
					height: 39rpx;
				}
			}
			.r-bottom-bg{
				margin-top:20rpx;
				margin-bottom: 10rpx;
				.vr-bg{
					width:92rpx;
					height:38rpx;
					border-radius: 6rpx;
					border: 0.5px solid #ff5f5f;
					font-size: 22rpx;
					color: #ff5f5f;
					text-align: center;
					display: flex;
					flex-direction: row;
					align-items: center;
					justify-content: center;
				}
			}
		}
		.stars {
			display: flex;
		}
		.store_name{
			font-weight: bold;
			font-size: 20px;
			color: #0b0b0b;
		}

		.star {
			width: 19px;
			height: 19px;
			display: none;
		}

		.addr {
			font-size: 13px;
			line-height: 1;
			color: #111;
			margin-top: 17px;
			max-width: 250px;
		}

		.time {
			font-size: 13px;
			line-height: 1;
			color: #333;
			margin-top: 14px;
		}

		.contact {
			position: absolute;
			right: 15px;
			bottom: 15px;

			.icon {
				width: 23px;
				height: 23px;
				display: block;
				margin: 0 auto;
			}

			.text {
				font-size: 11px;
				line-height: 1;
				text-align: center;
				color: #333;
				margin-top: 8px;
			}
		}
	}

	.comment-item {
		background-color: #fff;
		display: flex;
		padding: 15px;
		position: relative;

		.avatar {
			width: 44px;
			min-width: 44px;
			height: 44px;
			border-radius: 50%;
			margin-right: 12px;
		}

		.info {
			flex: 1;
		}
		
		.nickname {
			font-size: 16px;
			color: #111;
		}

		.time {
			font-size: 12px;
			color: #333;
			position: absolute;
			top: 20px;
			right: 15px;
		}

		.stars {
			display: flex;
			margin-top: 8px;
		}

		.star {
			width: 19px;
			height: 19px;
		}

		.content {
			font-size: 14px;
			line-height: 22px;
			color: #111;
			margin-top: 15px;
		}

		.images {
			display: flex;
			margin-top: 15px;
		}

		.image {
			width: 85px;
			height: 85px;
			border-radius: 5px;
			margin-right: 10px;
		}

		&:not(:last-child)::after {
			content: '\20';
			display: block;
			border-bottom: 1px solid #DCDCDC;
			position: absolute;
			right: 0;
			bottom: 0;
			left: 70px;
		}
	}

	.action-bar {
		background: #fff;
		position: fixed;
		right: 0;
		bottom: 0;
		left: 0;
		display: flex;
		align-items: center;
		padding: 20rpx 0;
		padding-bottom: calc(20rpx + constant(safe-area-inset-bottom));
		padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
		padding-left: 15px;
		padding-right: 15px;
		flex-direction: row;

		.price {
			flex: 1;
			font-size: 16px;
			color: #999;

			.value {
				font-weight: bold;
				font-size: 25px;
				color: #d82c2c;
			}
		}

		.book-now {
			height: 78rpx;
			border-radius: 39rpx;
			background: #0193ff;
			border: 1px solid #0193ff;
			font-family: "Source Han Sans CN Bold";
			font-weight: bold;
			font-size: 28rpx;
			line-height: 78rpx;
			text-align: center;
			color: #fff;
			flex:1;
			margin: 0px 15px;
		}
	}
</style>
